package com.example.springboot.mapper;

import com.example.springboot.bean.Notify;
import com.example.springboot.bean.NotifyStatus;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface NotifyMapper {

    @Select("SELECT\n" +
            "	*\n" +
            "FROM\n" +
            "	hyfc_notify a\n" +
            "LEFT JOIN hyfc_notify_status b ON a.id = b.notify_id\n" +
            "AND b.user_id = #{userId}\n" +
            "WHERE\n" +
            "	a.end_time > now()\n" +
            "	-- and b.id IS not NULL  -- 已读\n" +
            "	and b.id IS NULL         -- 未读")
    List<Notify> selectByUserId(int userId);

    @Insert("insert into hyfc_notify_status values(" +
            "default,#{notifyId},#{userId},default,#{status})")
    int insertStatus(NotifyStatus ns);

}
